"use strict";
cc._RF.push(module, '408d7F0WBNK/qXu4IOgS3aQ', 'level32');
// scripts/modes/normalMode/levelAvoid/level32/level32.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
Object.defineProperty(exports, "__esModule", { value: true });
var gameEngine_1 = require("../../../../engines/gameEngine");
var data_control_1 = require("../../../../engines/libs/data_control");
var levelAvoidEnemy_1 = require("../base/levelAvoidEnemy");
var levelAvoidPlayer_1 = require("../base/levelAvoidPlayer");
var levelAvoidBase_1 = require("../levelAvoidBase");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var level32 = /** @class */ (function (_super) {
    __extends(level32, _super);
    function level32() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.waveNode = [];
        _this.wave1Node = [];
        _this.wave2Node = [];
        return _this;
    }
    level32.prototype.Init = function (info) {
        return __awaiter(this, void 0, Promise, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, _super.prototype.Init.call(this, info)];
                    case 1:
                        _a.sent();
                        return [2 /*return*/];
                }
            });
        });
    };
    level32.prototype.setGameStart = function () {
        _super.prototype.setGameStart.call(this);
        // managers().soundMgr.playSound("level29/sound/startGame", () => { })
        this.wave3();
        // this.wave2();
        // this.wave3();
    };
    level32.prototype.wave1 = function () {
        var _this = this;
        this.scheduleOn(function () {
            gameEngine_1.managers().soundMgr.playSound("level32/sound/one", function () { });
        }, 2);
        var strListTargetY = 300;
        var strList = [
            "呃嘿哈喽，呃嘿呃就是",
            "刚刚在那边看到你",
            "感觉你闺蜜旁边的你",
            "还蛮可爱的"
        ];
        var starPosList = [
            cc.v2(-450, -300),
            cc.v2(-450, -600),
            cc.v2(0, -600),
            cc.v2(450, -600),
            cc.v2(450, -300)
        ];
        var delayTime = 0;
        var index = 0;
        for (var i = 0; i < strList.length; i++) {
            for (var j = 0; j < strList[i].length; j++) {
                index++;
            }
        }
        // 总时间为12秒
        var onceTime = 12 / index;
        index = 0;
        var speed = 30;
        var _loop_1 = function (i) {
            var list = strList[i].split("");
            var startPos = cc.v2((-44 * list.length / 2) + 22, strListTargetY - i * 60);
            var _loop_3 = function (j) {
                this_1.scheduleOn(function () {
                    var LabNode = _this.newLabNode();
                    _this.waveNode.push(LabNode.node);
                    _this.wave1Node.push(LabNode.node);
                    LabNode.init(list[j], _this.player.getComponent(levelAvoidPlayer_1.default), {
                        moveType: levelAvoidEnemy_1.EnemyMoveType.four,
                        moveSpeed: speed,
                        startPos: starPosList[index],
                        targetPos: [cc.v2(startPos.x + j * 44, startPos.y)]
                    }, _this);
                    LabNode.startAvoid();
                    index++;
                    index = index >= starPosList.length ? 0 : index;
                }, delayTime + j * onceTime);
            };
            for (var j = 0; j < list.length; j++) {
                _loop_3(j);
            }
            delayTime += list.length * onceTime;
        };
        var this_1 = this;
        for (var i = 0; i < strList.length; i++) {
            _loop_1(i);
        }
        var starPos2List = [
            cc.v2(-1000, -500),
            cc.v2(-1000, -1000),
            cc.v2(0, -1000),
            cc.v2(1000, -1000),
            cc.v2(1000, -500)
        ].sort(function () { return -1; });
        // 2
        delayTime = 0;
        var _loop_2 = function (i) {
            var list = strList[i].split("");
            var startPos = cc.v2((-44 * list.length / 2) + 22, strListTargetY - i * 60);
            var _loop_4 = function (j) {
                this_2.scheduleOn(function () {
                    var LabNode = _this.newLabNode();
                    _this.waveNode.push(LabNode.node);
                    _this.wave1Node.push(LabNode.node);
                    LabNode.init(list[j], _this.player.getComponent(levelAvoidPlayer_1.default), {
                        moveType: levelAvoidEnemy_1.EnemyMoveType.four,
                        moveSpeed: speed,
                        startPos: starPos2List[index],
                        targetPos: [cc.v2(startPos.x + j * 44, startPos.y)]
                    }, _this);
                    LabNode.startAvoid();
                    index++;
                    index = index >= starPosList.length ? 0 : index;
                }, delayTime + j * onceTime);
            };
            for (var j = 0; j < list.length; j++) {
                _loop_4(j);
            }
            delayTime += list.length * onceTime;
        };
        var this_2 = this;
        for (var i = 0; i < strList.length; i++) {
            _loop_2(i);
        }
        this.scheduleOn(function () {
            for (var _i = 0, _a = _this.wave1Node; _i < _a.length; _i++) {
                var node = _a[_i];
                var enemy = node.getComponent(levelAvoidEnemy_1.default);
                enemy.changeMoveData({
                    moveType: levelAvoidEnemy_1.EnemyMoveType.two,
                    moveSpeed: 30,
                    startPos: node.getPosition(),
                    moveDirection: cc.v2(0, -1)
                });
            }
        }, delayTime + 2);
        delayTime += 2;
        this.scheduleOn(function () {
            for (var _i = 0, _a = _this.waveNode; _i < _a.length; _i++) {
                var node = _a[_i];
                node.destroy();
            }
            _this.waveNode = [];
            _this.wave2();
        }, delayTime + 1);
    };
    level32.prototype.wave2 = function () { };
    level32.prototype.wave3 = function () {
        var _this = this;
        // this.node_ma.startAvoid(false);
        var labList = ["肥", "胖", "丑", "矮", "穷"];
        var posList = [cc.v2(-280, 280), cc.v2(-280, 0), cc.v2(-280, -280), cc.v2(280, 280), cc.v2(280, 0), cc.v2(280, -280)];
        for (var i = 0; i < labList.length; i++) {
            var LabNode = this.newLabNode();
            this.waveNode.push(LabNode.node);
            LabNode.init(labList[i], this.player.getComponent(levelAvoidPlayer_1.default), {
                moveType: 0,
                moveSpeed: 3,
                startPos: posList[i] //cc.v2(data_control.getRandNumberOfArrayTwo([-280, 280]), data_control.getRandNumberOfArrayTwo([-380, 380]))
            }, this, 1.25);
            LabNode.startAvoid();
        }
        this.scheduleAny(function () {
            var lab = labList[Math.floor(data_control_1.default.getRandNumberOfArrayTwo([0, labList.length]))];
            var LabNode = _this.newLabNode();
            _this.waveNode.push(LabNode.node);
            LabNode.node.scale = 1.5;
            LabNode.init(lab, _this.player.getComponent(levelAvoidPlayer_1.default), {
                moveType: 0,
                moveSpeed: 3,
                startPos: cc.v2(data_control_1.default.getRandNumberOfArrayTwo([-280, 280]), data_control_1.default.getRandNumberOfArrayTwo([-380, 380]))
            }, _this, 1.25);
            LabNode.startAvoid();
        }, 2);
    };
    // wave3() {
    //     this.node_tuo.startAvoid(false);
    //     // managers().soundMgr.playSound("mainSound/duobi/wave3_0")
    //     let labList: string[] = ["矮", "挫", "穷", "丑", "胖"]
    //     cc.tween(this.node_tuo.node)
    //         .to(0.5, { scale: 0 })
    //         .call(() => {
    //             this.node_tuo.node.destroy()
    //             // this.node_tuo.lab.fontSize = 60;
    //             // this.node_tuo.init("尬", this.player.getComponent(levelAvoidPlayer), {
    //             //     moveType: 0,
    //             //     moveSpeed: 3,
    //             //     startPos: cc.v2(0, 0)
    //             // }, this)
    //             // this.node_tuo.startAvoid();
    //         })
    //         .start()
    //     let posList: cc.Vec2[] = [cc.v2(-280, 280), cc.v2(-280, 0), cc.v2(-280, -280), cc.v2(280, 280), cc.v2(280, 0), cc.v2(280, -280)]
    //     let minScale = 0.5;
    //     let maxScale = 6;
    //     for (let i = 0; i < 6; i++) {
    //         let scale = data_control.getRandNumberOfArrayTwo([minScale, maxScale]);
    //         let LabNode = this.newLabNode();
    //         this.waveNode.push(LabNode.node)
    //         LabNode.init(labList[i], this.player.getComponent(levelAvoidPlayer), {
    //             moveType: EnemyMoveType.five,
    //             moveSpeed:3,
    //             startPos: posList[i],//cc.v2(data_control.getRandNumberOfArrayTwo([-280, 280]), data_control.getRandNumberOfArrayTwo([-380, 380]))
    //             rangleV4: new cc.Vec4(-280, 280, -380, 380)
    //         }, this, scale)
    //         LabNode.startAvoid()
    //         let way = 1;
    //         this.scheduleAny(() => {
    //             if (LabNode.scale > maxScale) {
    //                 way = -1;
    //             }
    //             else if (LabNode.scale < minScale) {
    //                 way = 1;
    //             }
    //             LabNode.scale += way * 0.06;
    //         })
    //     }
    //     // this.scheduleAny(() => {
    //     //     let lab = "尬";
    //     //     let LabNode = this.newLabNode();
    //     //     this.waveNode.push(LabNode.node)
    //     //     LabNode.node.scale = 1.5
    //     //     LabNode.init(lab, this.player.getComponent(levelAvoidPlayer), {
    //     //         moveType: 0,
    //     //         moveSpeed: 3,
    //     //         startPos: cc.v2((Math.random() > 0.5 ? 1 : -1) *data_control.getRandNumberOfArrayTwo([100, 280]), (Math.random() > 0.5 ? 1 : -1) * data_control.getRandNumberOfArrayTwo([100, 380]))
    //     //     }, this, 1.25)
    //     //     LabNode.startAvoid()
    //     // }, 1)
    // }
    level32.prototype.Lose = function (time) {
        this.unscheduleAllCallbacks();
        var pos = this.player;
        var jumpTime = cc.v3(100, -1000).sub(this.player.position).mag() / 800;
        // managers().soundMgr.playSound('mainSound/duobi/death').then();
        cc.tween(this.player)
            .parallel(cc.tween(this.player).bezierTo(jumpTime, this.player.getPosition(), cc.v2(this.player.x + 200, this.player.y + 500), cc.v2(this.player.x + 400, this.player.y - 1000)), cc.tween(this.player).to(4, { angle: -3000 }))
            .start();
        _super.prototype.Lose.call(this, jumpTime);
    };
    level32.prototype.Win = function (time, jyIndex, userStr) {
        var _this = this;
        this.unscheduleAllCallbacks();
        var endScale = this.player.scale;
        gameEngine_1.managers().soundMgr.playSound("fontChase/win").then();
        cc.tween(this.player)
            .to(0.2, { scale: 0.6 })
            .call(function () {
            _this.player.getChildByName("spwin").active = true;
        })
            .delay(2)
            .call(function () {
            var bo = _this.player.getChildByName("bo");
            bo.active = true;
            cc.tween(bo)
                .to(1, { scale: 5 })
                .call(function () {
                bo.active = false;
            })
                .start();
        })
            .to(0.2, { scale: 1 })
            .call(function () {
            var _loop_5 = function (node) {
                cc.tween(node)
                    .to(0.1, { scale: 1.1, opacity: 255 })
                    .to(0.1, { scale: 1, opacity: 100 })
                    .to(0.1, { scale: 1.1, opacity: 255 })
                    .to(0.1, { scale: 1, opacity: 100 })
                    .to(0.3, { scaleX: 1.2, scaleY: 0.8, opacity: 0 })
                    .call(function () {
                    node.destroy();
                })
                    .start();
            };
            for (var _i = 0, _a = _this.waveNode; _i < _a.length; _i++) {
                var node = _a[_i];
                _loop_5(node);
            }
            _super.prototype.Win.call(_this, 3);
        })
            .start();
    };
    level32 = __decorate([
        ccclass
    ], level32);
    return level32;
}(levelAvoidBase_1.default));
exports.default = level32;

cc._RF.pop();